/**
 * @author guocailee
 */
import Vue from 'vue'
/**
 * 发送验证码
 * @param  {[json]}
  "params": {
      "account": "99156629@qq.com",
      "inviteJoinCode": "9955dc13cf3c5e5822a3db35bb9d099c"
    }
  },
 */
export const sendCaptcha = (params) => {
  return new Promise((resolve, reject) => {
    Vue.fetch.post('content/base/captcha', params)
    .then(data => {
      if (data.body.code === '00000000') {
        resolve()
      } else {
        reject(data.body.message)
      }
    }).catch(data => {
      reject(data)
    })
  })
}

/**
 * 校验验证码
 * @param  {[object]} params [
 * params": {
      "account": "99156629@qq.com",
      "captcha": "381"
    }]
 */
export const verifyCaptcha = (params) => {
  return new Promise((resolve, reject) => {
    Vue.fetch.post('content/base/verifyCaptcha', params)
      .then(data => {
        if (data.body.code === '00000000') {
          resolve()
        } else {
          reject(data.body.message)
        }
      }).catch(data => {
        reject(data)
      })
  })
}
/**
 * 校验图片验证码
 * @param  {[object]}
 * "params": {
      "captcha": "WUfb"
    }
 */
export const verifyImgCode = (params) => {
  return new Promise((resolve, reject) => {
    Vue.fetch.post('content/base/verifyPictureCaptcha', params)
      .then(data => {
        if (data.body.code === '00000000') {
          resolve()
        } else {
          reject(data.body.message)
        }
      }).catch(data => {
        reject(data)
      })
  })
}
